<!DOCTYPE html>
<html>
    <head>
        <title>随机色效果</title>
    </head>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        body{
            width: 200px;
            height: 150px;
            font-size: medium; 
            padding: 20%;
            transition: 2s;
            display: flex;
            justify-content: content;
            align-items: center;
            background-color: #34495e;
            color: #34495e;
        }
    </style>
    <body>
        something is happened....
    </body>
    <script>
        function Color(elem){
            this.elem = elem;
            this.colors = ['#75b9ff','#ffeaa7','#fab1a0','#fd79a8'];
            this.run = function(){
                setInterval(() => {
                   let pos = Math.floor(Math.random()*this.colors.length);
                   this.elem.style.background = this.colors[pos];
                }, 1000);
            }
        }
        let obj = new Color(document.body);
        obj.run();
    </script>
</html>